//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.ComponentModel;
using System.Globalization;
using System.Windows;

namespace OpenLS.Spreadsheet
{
    class HorizontalAlignmentConverter : TypeConverter
    {
        public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
        {
            return sourceType == typeof(HorizontalAlignment);
        }
        public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
        {
            return destinationType == typeof(HorizontalAlignment);
        }

        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            HorizontalCellAlignment h = (HorizontalCellAlignment)value;
            switch (h)
            {
                case HorizontalCellAlignment.Right:
                    return HorizontalAlignment.Right;
                case HorizontalCellAlignment.Center:
                case HorizontalCellAlignment.CenterContinuous:
                    return HorizontalAlignment.Center;
                default: return HorizontalAlignment.Left;
            }
        }
    }
}